#!/bin/bash
# SDCARD TF 启动脚本
DEV=/dev/mmcblk1p1
MNT=/mnt/devstick
[[ $(id -u) -ne 0 ]] && exec sudo "$0" "$@"
# 1. 确保挂载点目录存在
mkdir -p "$MNT"
# 2. 如未挂载，则挂载
mountpoint -q "$MNT" || mount "$DEV" "$MNT"
# 3. 挂伪文件系统
mount -t proc  none "$MNT/proc"
mount -t sysfs none "$MNT/sys"
mount -o bind /dev "$MNT/dev"
mount -o bind /dev/pts "$MNT/dev/pts"
mount -o bind /run   "$MNT/run"
echo "=== Entering TF-card clean dev environment ==="
chroot "$MNT" /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
       PS1='(tf-dev)\u:\w\$ ' bash -l